/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.camera;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.BaseColumns;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;

import com.android.camera.rephoto.R;

/**
 * An activity that will edit the title of a note. Displays a floating
 * window with a text field.
 */
public class TitleEditor extends Activity implements View.OnClickListener {
    public static final String TAG="TitleEditor";
    static final String AUTHORITY="com.android.camera.rephoto";
    
    /**
     * Notes table
     */
    private static final class NoteColumns implements BaseColumns {
        // This class cannot be instantiated
        private NoteColumns() {}
    
        /**
         * The content:// style URL for this table
         */
        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/notes");
    
        /**
         * The MIME type of {@link #CONTENT_URI} providing a directory of notes.
         */
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.note";
    
        /**
         * The MIME type of a {@link #CONTENT_URI} sub-directory of a single note.
         */
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.google.note";
    
        /**
         * The default sort order for this table
         */
        public static final String DEFAULT_SORT_ORDER = "modified DESC";
    
        /**
         * The title of the note
         * <P>Type: TEXT</P>
         */
        public static final String TITLE = "title";
    
        /**
         * The note itself
         * <P>Type: TEXT</P>
         */
        public static final String NOTE = "note";
    
        /**
         * The timestamp for when the note was created
         * <P>Type: INTEGER (long from System.curentTimeMillis())</P>
         */
        public static final String CREATED_DATE = "created";
    
        /**
         * The timestamp for when the note was last modified
         * <P>Type: INTEGER (long from System.curentTimeMillis())</P>
         */
        public static final String MODIFIED_DATE = "modified";
    }

    /**
     * The EditText field from our UI. Keep track of this so we can extract the
     * text when we are finished.
     */
    private EditText mText;
   
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	 super.onCreate(savedInstanceState);
    	 
    	 setContentView(R.layout.title_editor);
     	
     	// Set up click handlers for the text field and button
         mText = (EditText) this.findViewById(R.id.title);
         
         Button b = (Button) findViewById(R.id.ok);
         b.setOnClickListener(this);
         
     	InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
     	imm.showSoftInput((View) mText.getWindowToken(), 0);
        // Get the uri of the note whose title we want to edit
        //mUri = getIntent().getData();

        // Get a cursor to access the note
        //mCursor = managedQuery(mUri, PROJECTION, null, null, null);

    	  

         
         
    }
    

   public void onClick(View v) {
        // When the user clicks OK, launch the rephoto camera activity
        // with whatever was entered as the meta-info for the project
        Intent intent=new Intent(Camera.REPHOTO_INTENT);
        intent.putExtra(Camera.PROJECT_NAME, mText.getText().toString());
        intent.putExtra(RephotoProvider.IS_ORIGINAL, "1");

        try {
            startActivity(intent);
        } finally {}
    }
}
